$(document).ready(function() {
    $(document).on('click', '#article-delete', function() {
        var id = $(this).data('article-id');

        var confirmation = confirm('确定要删除吗？');
        if (confirmation) {
            $.ajax({
                url: '/user/delete_article?article_id=' + id,
                method: 'POST',
                success: function(data) {
                    location.reload();
                }
            });
        }
    });

    $(document).on('click', '#article-sm', function() {
        var id = $(this).data('article-id');
        $.ajax({
            url: '/user/set_sm?article_id=' + id,
            method: 'POST',
            success: function(data) {
                $(this).text('已设为私密')
                location.reload();
            }
        });
    });

    $(document).on('click', '#article-edit', function() {
        var id = $(this).data('article-id');
        window.location.href = '/user/article_edit?article_id=' + id
    });

    $(document).on('click', '#article-access', function() {
        var id = $(this).data('article-id');
        $.ajax({
            url: '/user/judge_article?article_id=' + id + '&type=1',
            method : 'POST',
            success : function(data) {
                location.reload();
            }

        })

    });
    $(document).on('click', '#article-pass', function() {
        var id = $(this).data('article-id');
        $.ajax({
            url: '/user/judge_article?article_id=' + id + '&type=2',
            method : 'POST',
            success : function(data) {
                location.reload();
            }

        })
    });

    $(document).on('click', '#cancle-col', function() {
        var id = $(this).data('article-id');
        $.ajax({
            url: '/cancel_favorite?id=' + id,
            method : 'POST',
            success : function(data) {
                location.reload();
            }

        })
    });

});


